package com.example.demo3_;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final EditText editText_user=findViewById(R.id.edit_user);
        final EditText editText_password=findViewById(R.id.edit_password);
        final ImageView imageView_login=findViewById(R.id.image_login);
        Button button_login=findViewById(R.id.button_login);
        button_login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String user=editText_user.getText().toString();
                String password=editText_password.getText().toString();
                Toast.makeText(MainActivity.this,"账号:"+user+"\n密码:"+password,Toast.LENGTH_SHORT).show();
                //改变图片的显示状态
                if(imageView_login.getVisibility()==View.VISIBLE){
                    imageView_login.setVisibility(View.INVISIBLE);
                }else {
                    imageView_login.setVisibility(View.VISIBLE);
                }
            }
        });
    }
}
